<template name='auditLog'>
	<section class="page-container page-home page-static rc-audit">
		{{# header sectionName="Message_auditing_log" hideHelp=true}}{{/header}}
		<form class="rc-form--inline rc-audit-form">
			<div class="rc-input rc-input--small rc-audit-date">
				<label class="rc-input__label">
					<div class="rc-input__title">{{_"Date_From"}}</div>
					<div class="rc-input__wrapper">
						<div class="rc-input__icon">
							{{> icon icon="lock"}}
						</div>
						<input name="startDate" type="date" class="rc-input__element"/>
					</div>
				</label>
			</div>
			<div class="rc-input rc-input--small rc-audit-date">
				<label class="rc-input__label">
					<div class="rc-input__title">{{_"Date_to"}}</div>
					<div class="rc-input__wrapper">
						<div class="rc-input__icon">
							{{> icon icon="lock"}}
						</div>
						<input name="endDate" type="date" class="rc-input__element"/>
					</div>
				</label>
			</div>
			<button type="button" class='rc-button rc-button--primary js-submit{{# if isLoading}} loading{{/if}}' name="button">{{_"Apply"}}</button>
		</form>
		<div class="rc-audit-container">
			{{#if isLoading}}
				{{> loading class="loading-animation--primary"}}
			{{else}}
				{{# if logs}}
				<!-- TODO: review this titles and labels -->
					<table class="rc-table rc-table--audit">
						<thead class="rc-table-head">
							<tr class="rc-table-tr">
								<td class="rc-table-td rc-audit-user-td">{{_'Username'}}</td>
								<td class="rc-table-td">Looked for</td>
								<td class="rc-table-td rc-audit-created-td">When</td>
								<td class="rc-table-td rc-audit-results-td">Results</td>
								<td class="rc-table-td rc-audit-created-td">Filter applied</td>
							</tr>
						</thead>
						<tbody class="rc-table-body">
							{{#each logs}}
								{{> auditLogItem}}
							{{/each}}
						</tbody>
					</table>
				{{else}}
					{{> roomSearchEmpty class="rc-audit-empty"}}
				{{/if}}
			{{/if}}
		</div>
	</section>
</template>

<template name="auditLogItem">
	<tr class="rc-table-tr" data-name="{{username}}">
		<td class="rc-table-td rc-audit-user-td">
			<div class="rc-audit-user__avatar">
				{{> avatar username=u.username}}
			</div>
			<div class="rc-audit-user__username">
				{{u.username}}
			</div>
		</td>
		<td class="rc-table-td rc-table-td-createdAt">{{msg}}</td>
		<td class="rc-table-td rc-audit-created-td">{{ts}}</td>
		<td class="rc-table-td rc-audit-results-td">{{results}}</td>
		<td class="rc-table-td rc-audit-created-td">{{{fields}}}</td>
	</tr>
</template>
